limsLocationBoard.editPage = {

    getGridParam: function () {
        var _this = this;
        return {
            type: 'grid',
            id: 'lims-location-board-edit-list-grid',
            url: limsLocationBoard.baseUrl + '/queries/raw',
            service: 'limsLocationBoardServiceImpl',
            dbTable: 'T_LIMS_LOCATION_BOARD',
            columns: limsLocationBoard.getEditListColumns(),
            onLoadSuccess: function (data) {
                if (!Gikam.isEmpty(data)) {
                    this.activeRowByIndex(0);
                } else {
                    // Gikam.cleanCompData(['sample-Location']);
                }
            },
            onRowActive: function (index, row) {
/*                Gikam.postSync(limsLocationBoard.holeUrl + '/queries', Gikam.getJsonWrapper({
                    f: {
                        boardId_EQ: row.id
                    },
                    n: -1, s: -1
                })).done(function (data) {
                    if (Gikam.isEmpty(data.rows)) {
                        Gikam.getComp('sample-Location').rowNum = 0;
                    } else {
                        Gikam.getComp('sample-Location').setData(data.rows);
                    }
                });*/
            },
            filterOpen: true,
            toolbar: [{
                type: 'button',
                text: 'GIKAM.BUTTON.INSERT',
                icon: 'add',
                onClick: function () {
                    Gikam.preInsert({
                        modalTitle: 'GIKAM.BUTTON.INSERT',
                        fields: limsLocationBoard.getBaseInfoFormFields(),
                        url: limsLocationBoard.baseUrl
                    }).done(function (id) {
                        Gikam.getComp('lims-location-board-edit-list-grid').refresh();
                        limsLocationBoard.loadSimpleBoardHoleDetailPage({id:id})
                    });
                }
            }, {
                type: 'button',
                text: 'GIKAM.BUTTON.DELETE',
                icon: 'remove-row',
                onClick: function () {
                    Gikam.getComp('lims-location-board-edit-list-grid').deleteRows(limsLocationBoard.baseUrl);
                }
            }],
            deleteFormatter: function (row) {
                return row.boardCode;
            },
            page: true,
            requestData: {
                createdByOrgId_EQ: workspace.user.ext$.loginorgid,
            },
            onCellClick: function (field, row) {
                field === 'boardCode' && limsLocationBoard.loadSimpleBoardHoleDetailPage(row)
            },
        }
    },

    getBaseInfoTab: function () {
        var _this = this;
        return {
            type: 'tab',
            panels: [{
                title: 'BASELINE.SAMPLEMANAGE.LOCATIONS.TAB.BASE_INFO',
                items: [{
                    type: 'form',
                    service: 'limsLocationBoardServiceImpl',
                    dbTable: 'T_LIMS_LOCATION_BOARD',
                    id: 'lims-location-board-edit-list-base-info-form',
                    fields: limsLocationBoard.getBaseInfoFormFields(),
                    onUpdated: function () {
                        var grid = Gikam.getComp('lims-location-board-edit-list-grid');
                        grid.refreshRowById(grid.getActivedRow().id);
                    },
                }]
            }]
        }
    },


/*    getHoleTab: function () {
        var _this = this;
        return {
            type: 'sampleLocation',
            id: 'sample-Location',
            bgIcon: {
                blood: '/static/lsi/img/location/blood.svg',
                cell: '/static/lsi/img/location/stem-cell.svg',
                dna: '/static/lsi/img/location/dna.svg'
            },
            bgColor: {
                in: 'green',
                out: 'blue',
            },
            rowNum: 0,
            colNum: 0,
            // width: 800,
            // height: 800,
            data: [],
            onClick: function (data) {
                console.log(data);
                let form = Gikam.getComp('location-hole-info-form');
                if (data.sampleId) {
                    form.refresh({
                        url: Gikam.printf(limsLocationBoard.sampleUrl + '/{id}', {
                            id: data.sampleId
                        })
                    });
                } else {
                    form.cleanData();
                }
            },
            onDbclick: function (data) {
            },
            onRendered: function (data) {
            }
        }
    },

    getHoleInformTab: function () {
        var _this = this;
        return {
            id: 'location-hole-info-form',
            type: 'form',
            titleWidthAuto: true,
            readonly: true,
            fields: limsLocationBoard.getHoleDetailInfoFormFields(),
            columns: 3,
        }
    },*/

    loadBatchDetailPage: function (id) {
        var _this = this;
        Gikam.create('modal', {
            height: '90%',
            width: '90%',
            title: 'BASELINE.BUSINESS.BATCH.MODAL.DETAIL',
            url: IFM_CONTEXT + '/secure/baseline/business/batchs/page/detail-top' + Gikam.param({
                id: id
            }),
        })
    },

    create: function () {
        var _this = this;
        Gikam.create('layout', {
            id: 'lims-location-board-edit-list-layout',
            renderTo: workspace.window.$dom,
            center: {
                title: 'T_LIMS_LOCATION_BOARD.GRID.TITLE',
                items: [this.getGridParam()]
            }
/*            west: {
                width: '40%',
                title: 'T_LIMS_LOCATION_BOARD.GRID.TITLE',
                items: [this.getGridParam()]
            },
            center: {
                title: 'MODULE.BASEDATA.LOCATION.TREE.LOCATIONS.HOLE',
                items: [{
                    type: 'layout',
                    center: {
                        items: [_this.getHoleTab()]
                    },
                    south: {
                        height: 100,
                        title: 'MODULE.BUSINESS.ORDERTASK.TAB.SAMPLE_INFO',
                        items: [_this.getHoleInformTab()]
                    }
                }]
            }*/
        });
    },

    init: function () {
        this.create();
    }
};
